﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            //比较两个日期，输出较为靠近现在的
            string beforeTime = "2010-10-11";
            DateTime t1 = Convert.ToDateTime(beforeTime);
            string newTime = "2019-12-11";
            DateTime t2 = Convert.ToDateTime(newTime);
            if (t1 > t2)
            {
                Console.WriteLine(t1);
            }
            else
            {
                Console.WriteLine(t2);
            }
            //现在的时间
            DateTime dateTime = DateTime.Now;
            Console.WriteLine(dateTime);
            //出生的时间
            string egg = "2001-09-04";
            DateTime eggday = Convert.ToDateTime(egg);
            //我的年龄
            int age = dateTime.Year - eggday.Year;
            Console.WriteLine("我今年已经"+age+"岁了");
            //字符串
            string str = " !  今天是个好日子";
            Console.WriteLine("本字符串的长度" + str.Length);
            Console.WriteLine("本字符串的第一个字段" + str[0]);
            //取消字符串的前置空格
            string newstr = str.Trim(' ');
            //删除第二个到第四个字段
            Console.WriteLine(str.Remove(2, 4));


        }
    }
}
